#ifndef CHATUSERWID_H
#define CHATUSERWID_H

#include <QDateTime>
#include <QLabel>
#include <QMouseEvent>
#include <QWidget>
#include <qcoreevent.h>

namespace Ui {
class ChatUserWid;
}

class ChatUserWid : public QWidget
{
    Q_OBJECT

public:
    explicit ChatUserWid(const QString& name, const int notLoaded, const int num = 1, QWidget *parent = nullptr);
    explicit ChatUserWid(const QString& name, QWidget *parent = nullptr);
    ~ChatUserWid();

    void setTime(const QDateTime& time);
    const QString getName() const;
    void setNews(const QString& news);
    void setPioneer(const unsigned int);
    void setNotLoaded(const unsigned int num);
    unsigned int getPioneer() const;
    unsigned int& getNotLoaded();
    void setContactsStyle();
    void setHeadPortrait(const QPixmap& p);
    void closeRedDot();
    void addOne();
    void pitchOn();
    void setGroupRoom(const QString& uuid);
    bool isGroup();
    const QString& getUUID();

    QSize sizeHint() const override ;

protected:
    void enterEvent(QEnterEvent *event) override ;
    void leaveEvent(QEvent *event) override ;
    void mousePressEvent(QMouseEvent *event) override ;

private:
    QString updateLabelDisplay(const QDateTime &targetTime);

signals:
    void sig_switch_user(const QString&);

private:
    Ui::ChatUserWid *ui;
    bool _isGroup{false};
    QString _name;
    QString _uuid;
    int _num{1};
    unsigned int _unread{0};
    unsigned int _notLoaded{0};//剩余需要加载的消息数
    unsigned int _pioneer{0};//当前的消息id
};

#endif // CHATUSERWID_H
